package com.xhcl.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xhcl.common.annotation.Log;
import com.xhcl.common.enums.BusinessType;
import com.xhcl.system.domain.TSrhsHsxtcs;
import com.xhcl.system.service.ITSrhsHsxtcsService;
import com.xhcl.common.core.controller.BaseController;
import com.xhcl.common.core.domain.AjaxResult;
import com.xhcl.framework.uitls.poi.ExcelUtil;
import com.xhcl.common.core.page.TableDataInfo;

/**
 * 核算系统参数Controller
 * 
 * @author xhcl
 * @date 2020-09-02
 */
@Controller
@RequestMapping("/system/hsxtcs")
public class TSrhsHsxtcsController extends BaseController
{
    private String prefix = "system/hsxtcs";

    @Autowired
    private ITSrhsHsxtcsService tSrhsHsxtcsService;

    @RequiresPermissions("system:hsxtcs:view")
    @GetMapping()
    public String hsxtcs()
    {
        return prefix + "/hsxtcs";
    }

    /**
     * 查询核算系统参数列表
     */
    @RequiresPermissions("system:hsxtcs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSrhsHsxtcs tSrhsHsxtcs)
    {
        startPage();
        List<TSrhsHsxtcs> list = tSrhsHsxtcsService.selectTSrhsHsxtcsList(tSrhsHsxtcs);
        return getDataTable(list);
    }

    /**
     * 导出核算系统参数列表
     */
    @RequiresPermissions("system:hsxtcs:export")
    @Log(title = "核算系统参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSrhsHsxtcs tSrhsHsxtcs)
    {
        List<TSrhsHsxtcs> list = tSrhsHsxtcsService.selectTSrhsHsxtcsList(tSrhsHsxtcs);
        ExcelUtil<TSrhsHsxtcs> util = new ExcelUtil<TSrhsHsxtcs>(TSrhsHsxtcs.class);
        return util.exportExcel(list, "hsxtcs");
    }

    /**
     * 新增核算系统参数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存核算系统参数
     */
    @RequiresPermissions("system:hsxtcs:add")
    @Log(title = "核算系统参数", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSrhsHsxtcs tSrhsHsxtcs)
    {
        return toAjax(tSrhsHsxtcsService.insertTSrhsHsxtcs(tSrhsHsxtcs));
    }

    /**
     * 修改核算系统参数
     */
    @GetMapping("/edit/{csdm}")
    public String edit(@PathVariable("csdm") String csdm, ModelMap mmap)
    {
        TSrhsHsxtcs tSrhsHsxtcs = tSrhsHsxtcsService.selectTSrhsHsxtcsById(csdm);
        mmap.put("tSrhsHsxtcs", tSrhsHsxtcs);
        return prefix + "/edit";
    }

    /**
     * 修改保存核算系统参数
     */
    @RequiresPermissions("system:hsxtcs:edit")
    @Log(title = "核算系统参数", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSrhsHsxtcs tSrhsHsxtcs)
    {
        return toAjax(tSrhsHsxtcsService.updateTSrhsHsxtcs(tSrhsHsxtcs));
    }

    /**
     * 删除核算系统参数
     */
    @RequiresPermissions("system:hsxtcs:remove")
    @Log(title = "核算系统参数", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSrhsHsxtcsService.deleteTSrhsHsxtcsByIds(ids));
    }
}
